﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>新增工作日报</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
    <link href="../Frozenui1.3/css/frozen.css" rel="stylesheet" />
    <link href="../JS/Date/FT_Date.min.css" rel="stylesheet" />
    <script src="../JS/layer/layer.m.js"></script>
    <style type="text/css">
        .ui-select {
            border: none;
            border: 0;
            background-color: #fff;
            appearance: none;
            -moz-appearance: none; /* Firefox */
            -webkit-appearance: none; /* Safari 和 Chrome */
        }
        #imglist img{width:150px;height:150px;}
    </style>
</head>
<body ms-controller="rbmodel">
    <div class="ui-footer ui-footer-stable ui-btn-group ui-border-t">
        <button class="ui-btn-lg ui-btn-primary" ms-click="savedata()">
            新增工作日报
        </button>
    </div>
    <section class="ui-container">
        <div class="ui-form ui-border-t">
            <div class="ui-form-item ui-border-b ">
                <label>
                    类型
                </label>
                <div class="ui-select ui-border-b">
                    <select ms-duplex="ctData.Remark"></select>
                </div>
            </div>
            <div class="ui-form-item ui-border-b">
                <label>
                    时间
                </label>
                <div class="ui-select ui-border-b">
                    <input type="text" placeholder="2015-07-10" id="appSDate" ms-duplex="ctData.RBDate" style="padding-left:0" />
                </div>
            </div>
            <div class="ui-form-item ui-border-b" style="height:auto;min-height:44px">
                <label>
                    内容
                </label>
                <div class="ui-txt-muted ui-whitespace" style="padding-left: 95px;text-align:justify" id="hdjj" ms-click="bjk()">请输入内容</div>
                <!--<input type="text" placeholder="请输入内容" ms-duplex="ctData.RBContent" />-->
            </div>
            <div class="ui-form-item ui-border-b">
                <label>
                    完成情况
                </label>
                <input type="text" placeholder="请输入完成情况" ms-duplex="ctData.RBWCQK" />

            </div>
            <div class="ui-form-item ui-border-b">
                <label>
                    图片
                </label>

            </div>
            <div class="ui-form-item ui-form-item-textarea ui-border-b">
                <div id="imglist">
                    
                </div>
                <a class="ui-icon-add"></a>
            </div>

        </div>
    </section>
    <script src="http://cdnjs.gtimg.com/cdnjs/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="../JS/Date/FT_Date.min.js"></script>
    <script>
        var jq = $.noConflict();
        jq(function () {
            var currYear = (new Date()).getFullYear();
            var opt = {
                date: { preset: 'date' },
                defaultopi: {
                    theme: 'android-ics light', //皮肤样式
                    display: 'modal', //显示方式
                    mode: 'scroller', //日期选择模式
                    lang: 'zh',
                    startYear: currYear - 5, //开始年份
                    endYear: currYear + 5, //结束年份
                    onSelect: function (valueText, inst) {
                        model.ctData.RBDate = valueText;
                    }
                }
            };
            jq("#appSDate").scroller(jq.extend(opt['date'], opt['defaultopi'])).scroller('setDate', new Date(), true);
            model.ctData.RBDate = jq("#appSDate").val();
        })
    </script>
    <script src="../JS/zepto.min.js"></script>
    <script src="../Frozenui1.3/js/frozen.js"></script>
    <script src="../JS/avalon.min.js"></script>

   <!-- <script src="../JS/wxconfig.js"></script>-->
    <script src="../JS/MobileCom.js?v=1.1"></script>
        <script type="text/javascript">
            define = null;
            require = null;
        </script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script>
       
        //if (MobileCom.getCookie("szhlcode") == null) {
        //    MobileCom.setCookie("szhlcode", "b2a7c203-16b1-4aed-9fe7-d3d147e963f9", 7);
        //}
        var width = 0;
        var model = avalon.define({
            $id: "rbmodel",
            ctData: { "Remark": "", "RBDate": "", "RBContent": "", "RBWCQK": "", "Files": "" },
            savedata: function () {
                var lg = $.loading({
                    content: '保存中...',
                })
                var imgurl = "";
                $("#imglist img").each(function (index, item) {
                    if (imgurl != "") {
                        imgurl += ",";
                    }
                    imgurl += $(item).attr("src");

                })
                
                //model.ctData.Files = imgurl;
                $.post("/API/WXAPI.ashx?Action=ADDGZRZ&r=" + Math.random(), { "P1": JSON.stringify(model.ctData.$model) }, function (data) {
                    lg.hide();
                    var data = $.parseJSON(data);
                    if (data.ErrorMsg == "") {
                        $("button").hide();
                        var el = $.tips({
                            content: "保存成功！",
                            stayTime: 2000,
                            type: "success"
                        })
                        el.on("tips:hide", function () {
                            window.location.reload();
                        })
                    }
                    else {
                        $.tips({
                            content: "保存失败，原因：" + data.ErrorMsg,
                            stayTime: 2000,
                            type: "warn"
                        })
                    }
                })
            },
            bjk: function () {

                var tc = layer.open({
                    type: 1,
                    //content:$("#bmxx").html(),
                    //title: "活动简介",
                    content: '<div class="ui-form-item ui-form-item-textarea ui-border-b" style="width:' + (width - 76) + 'px;height:200px"><textarea id="hdjjbjk" style="padding-left: 0;height:170px;border: 1px solid #e0e0e0;" placeholder="请输入内容">' + model.ctData.RBContent + '</textarea></div>',
                    btn: ['确认', '取消'],
                    shadeClose: false,
                    yes: function () {
                        model.ctData.RBContent = $("#hdjjbjk").val();
                        if ($("#hdjjbjk").val() != "") {
                            $("#hdjj").removeClass("ui-txt-muted");
                            $("#hdjj").html($("#hdjjbjk").val());
                        }
                        else {
                            $("#hdjj").addClass("ui-txt-muted");
                            $("#hdjj").html("请输入内容");
                        }

                        layer.close(tc);

                    }, no: function () {
                    }
                })
            }

        });

        avalon.ready(function () {
            width = document.documentElement.clientWidth;
            var lg = $.loading({
                content: '加载中...',
            })
            $.post("/API/WXAPI.ashx?Action=GETCOLUMNLIST&r="+Math.random(), { "P1": "7" }, function (data) {
                lg.hide();
                var data = $.parseJSON(data);
                if (data.ErrorMsg == "") {
                    $("select").empty();
                    for (var i = 0; i < data.Result.length; i++) {
                        $("select").append('<option value="' + data.Result[i].TypeNO + '">' + data.Result[i].TypeNO + '</option>');
                        if (i == 0) {
                            model.ctData.Remark = data.Result[i].TypeNO;
                        }
                    }
                }
                else {
                    $.tips({
                        content: "类型加载失败，原因：" + data.ErrorMsg,
                        stayTime: 2000,
                        type: "warn"
                    })
                }
            })

            $.getJSON("/API/WXAPI.ashx?action=JSSDKGETSIGNAGURE&r=" + Math.random(), { "P1": window.location.href }, function (r) {
                if (r.ErrorMsg == "") {

                    wx.config({
                        debug: false,
                        appId: r.Result.appId,
                        timestamp: r.Result.timestamp,
                        nonceStr: r.Result.noncestr,
                        signature: r.Result.signature,
                        jsApiList: [
                          'checkJsApi',
                          'onMenuShareTimeline',
                          'onMenuShareAppMessage',
                          'onMenuShareQQ',
                          'onMenuShareWeibo',
                          'hideMenuItems',
                          'showMenuItems',
                          'hideAllNonBaseMenuItem',
                          'showAllNonBaseMenuItem',
                          'translateVoice',
                          'startRecord',
                          'stopRecord',
                          'onRecordEnd',
                          'playVoice',
                          'pauseVoice',
                          'stopVoice',
                          'uploadVoice',
                          'downloadVoice',
                          'chooseImage',
                          'previewImage',
                          'uploadImage',
                          'downloadImage',
                          'getNetworkType',
                          'openLocation',
                          'getLocation',
                          'hideOptionMenu',
                          'showOptionMenu',
                          'closeWindow',
                          'scanQRCode',
                          'chooseWXPay',
                          'openProductSpecificView',
                          'addCard',
                          'chooseCard',
                          'openCard'
                        ]
                    })


                    $(".ui-icon-add").click(function () {

                        wx.chooseImage({
                            success: function (res) {
                                $(res.localIds).each(function (index) {
                                    $("#imglist").append("<img id='img_" + index + "' src='" + res.localIds[index] + "' src_wx=''  />");

                                    //wx.uploadImage({
                                    //    localId: res.localIds[index], // 需要上传的图片的本地ID，由chooseImage接口获得
                                    //    isShowProgressTips: 0,// 默认为1，显示进度提示
                                    //    success: function (res) {
                                    //        var serverId = res.serverId; // 返回图片的服务器端ID
                                    //        $("#imglist").find("#img_" + index).attr("src_wx", serverId);
                                    //    }
                                    //});

                                   
                                })

                            }
                        });
                    })


                } else {
                    alert("error");
                }

            })





        })
    </script>

</body>
</html>
